package cn.ycxy.lbl.repairs.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Knife4j（Swagger2）的配置
 */
@Configuration
@EnableSwagger2WebMvc
@Slf4j
public class Knife4jConfiguration {

    public Knife4jConfiguration(){
        log.info("加载Knife4jConfiguration...");
    }

    @Bean(value = "repairs")
    public Docket repairs() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("CS 报修服务中心在线API")
                        .description("CS 报修服务中心在线API")
                        .termsOfServiceUrl("")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("JSD组")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("cn.ycxy.lbl.repairs.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

}
